package com.itheima.boottlias.mapper;

import com.itheima.boottlias.domain.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 部门持久层接口
 * @author ghy
 * @version 1.0
 * @since 2025-07-10 10:32
 */
@Mapper
public interface DeptMapper {

    /**
     * 查询所有
     * @return 部门列表
     */
    // @Results({
    //         @Result(column = "create_time", property = "createTime"),
    //         @Result(column = "update_time", property = "updateTime")
    // })
    // @Select("select id, name, create_time createTime, update_time updateTime from dept")
    @Select("select * from dept")
    List<Dept> findAll();

    /**
     * 根据ID删除
     * @param id 部门ID
     * @return
     */
    @Delete("delete from dept where id = #{id}")
    Integer deleteById(Integer id);

    @Insert("insert into dept (name, create_time, update_time) values (#{name}, #{createTime}, #{updateTime})")
    Integer insert(Dept dept);

    @Select("select * from dept where id = #{id}")
    Dept findById(Integer id);

    @Update("update dept set name=#{name}, update_time=#{updateTime} where id=#{id}")
    void updateById(Dept dept);
}
